"""
author: liuxu
date: 2025/5/1
description: 此模块用于测试--rccl-trace功能
"""
import allure
import pytest
import re
from common.logger_ctrl import mylogger
from common.ssh_command import exec_cmd
from base_public.testbase import BasePublic
from setting import CPP_DIR, EXE_DIR

@allure.feature('rccl tracing指令')
@pytest.mark.medium
class TestRcclTrace(BasePublic):
    """测试rccl trace功能"""
    @pytest.mark.smoke
    @pytest.mark.high
    def test_rccl_trace(self, test_env):
        """
        测试hipprof --rccl-trace ./简单程序
        :param test_env:
        :return:
        """
        # 编译待测用例
        exe_path = self.compile_source_code(src_file_name="RcclCase/singleProcess.cpp", compile_paras="-lrccl")

        # 执行测试命令
        ret, output = exec_cmd(f"hipprof --rccl-trace {exe_path}", cwd=test_env)
        assert ret is True
        assert "|ncclAllReduce" in output and "Kernel_AllReduce_Ring" in output
        #TODO编写解析rccl文件的公共方法
